﻿#include "judgeFileAndDeal.h"

multideal::multideal(){




}

multideal::~multideal(){


}
bool   multideal::judgeXlsFile(QString filename){

    QString xlssuffix = "xls";

    QFileInfo fi(filename);
    QString est = fi.completeSuffix();

    if(xlssuffix == est)
        return true;
    return false;

}

bool    multideal::judgeDbFile(QString filename){

    QString dbsuffix = "db";

    QFileInfo fi(filename);
    QString est = fi.completeSuffix();

    if(dbsuffix == est)
        return true;
    return false;

}

QVariant  multideal::dbFileDeal(QString filename){
    {
        db = QSqlDatabase::addDatabase("QSQLITE");

        db.setDatabaseName(filename);

        if(!db.open()){
            return false;
        }
    }
        QStringList tables = db.tables();
        QString     table = tables.at(0);

    return table;

}


void    multideal::removeConnection(){

    QString connectionName;
    /**
      *@brief  报错
        QSqlDatabasePrivate::addDatabase: duplicate connection name
                'qt_sql_default_connection',old connection removed.*/

    {
        connectionName = QSqlDatabase::database().connectionName();
        qDebug()<<connectionName;
        db.close();
    }
     QSqlDatabase::removeDatabase(connectionName);

}
